using MongoDB.Driver;
using Sustainalytics.Synchronization.Validation.Handlers.Common;
using Sustainalytics.Synchronization.Validation.Internals;
using Sustainalytics.Synchronization.Validation.ValidationRules.Comprehensive;
using Sustainalytics.Synchronization.Validation.Validators;
using System;
using Sustainalytics.ESG.Entities;

namespace Sustainalytics.Synchronization.Validation.Handlers.Comprehensive
{
    public class KeyESGIssueHandler : Handler<CompanyKeyESGIssue, ComprehensiveCompanies>
    {
        public KeyESGIssueHandler(ComprehensiveCompanies comprehensiveCompanies, ValidationMongoCollection<CompanyKeyESGIssue> collection, ComprehensiveValidator<CompanyKeyESGIssue> validator)
            : base(comprehensiveCompanies, collection, validator)
        {
        }

        protected override ProjectionDefinition<CompanyKeyESGIssue> GetProjectionDefinition()
        {
            return Builders<CompanyKeyESGIssue>.Projection.Include(x => x.Id).Include(x => x.KeyESGIssues);
        }

        protected override FilterDefinition<CompanyKeyESGIssue> GetReferenceEntityFilter(CompanyKeyESGIssue validatedEntity)
        {
            return Builders<CompanyKeyESGIssue>.Filter.Where(x => x.Id == validatedEntity.Id);
        }

        protected override FilterDefinition<CompanyKeyESGIssue> GetValidatedEntityFilterDefinition(Guid companyId)
        {
            return Builders<CompanyKeyESGIssue>.Filter.Where(x => x.Id == companyId);
        }
    }
}
